Examples > Creating the Database Schema from a Snapshot |
The following example shows how to create the schema of the database from a snapshot file.
using System; using System.Collections.Generic; using System.Text; using System.IO; using xSQL.Schema.Core; using xSQL.Schema.SqlServer; using xSQL.SchemaCompare.SqlServer; namespace xSQL.Sdk.SchemaCompare.Examples { class DatabaseSnapshot { /// <summary> /// Creates the AdventureWorks database from a snapshot file. /// </summary> public static void CreateDatabaseFromSnapshot() { SqlDatabase database; SqlTable table; ScriptingOptions options; try { //--create the database from the snapshot file database = SqlDatabase.CreateFromSnapshot(@"C:\AdventureWorks.snpx"); //--script the Employee table options = new ScriptingOptions(); options.CreateScript = true; options.DropScript = false; options.AlterScript = false; table = database.SqlTables["HumanResources", "Employee"]; if (table != null) Console.Write(table.GetScript(options)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } }